package com.lancoo.znbkxx.utils;

import android.Manifest;
import android.support.v7.app.AppCompatActivity;

import com.lancoo.znbkxx.base.IOCallBack;
import com.tt.widget.PermissionsManager;
import com.tt.widget.PermissionsResultAction;

/**
 * Create by TangJun on 2019/2/16
 */
public class AppPermissionsChecker { public void check(AppCompatActivity context, final IOCallBack<Boolean> callBack){
    PermissionsManager.getInstance().requestPermissionsIfNecessaryForResult(
            context,
            new String[]{
                    Manifest.permission.INTERNET,
                    Manifest.permission.WRITE_EXTERNAL_STORAGE,
                    Manifest.permission.ACCESS_NETWORK_STATE,
                    Manifest.permission.ACCESS_WIFI_STATE,
                    Manifest.permission.READ_EXTERNAL_STORAGE,
                    Manifest.permission.WAKE_LOCK,
            },
            new PermissionsResultAction() {
                @Override
                public void onGranted() {
                    if(callBack!=null){
                        callBack.onBack(true);
                    }
                }

                @Override
                public void onDenied(String permission) {
                    if(callBack!=null){
                        callBack.onBack(false);
                    }

                }
            }
    );
}

}
